package drds.global_transaction.image.image_praser;

import drds.common.Author;
import drds.global_transaction.Authors;
import drds.global_transaction.image.Image;
import drds.global_transaction.image.UndoLog;
import net.sf.jsqlparser.JSQLParserException;

import java.sql.SQLException;

@Author(name = Authors.LI_YANG)
public class SelectIImagePraser extends ImagePraser
{

    SelectIImagePraser(String originalSql, UndoLog undoLog)
    {
        this.originalSql = originalSql;
        this.undoLog = undoLog;
    }


    @Override
    public String getTableName() throws JSQLParserException, SQLException
    {
        return SqlPraser.selectSentenceTableName(originalSql);
    }

    @Override
    public String getWhereCondition() throws JSQLParserException
    {
        return SqlPraser.selectSentenceWhereCondition(originalSql);
    }

    @Override
    public Image generateBeforeImage() throws JSQLParserException, SQLException
    {
        return getImage();

    }

    @Override
    public Image generateAfterImage()
    {
        return null;
    }

    @Override
    public String getBeforeOrAfterImageSql() throws JSQLParserException
    {
        return imageSql;
    }

}
